package com.capgemini.business.mapper;

import com.capgemini.business.entity.Files;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FilesMapper {
    // Retrieve查询接口
    @Select("SELECT * FROM files")
    List<Files> findAll();
    // 通过id查询
    @Select("SELECT * FROM files WHERE id = #{id}")
    Files findById(Long id);  // 通常用Long类型表示数据库表中的主键字段

    // Create新增接口
    @Insert("INSERT INTO files (id, name, username, position, level, date, phone, email, department) " +
            "VALUES (#{id}, #{name}, #{username}, #{position}, #{level}, #{date}, #{phone}, #{email}, #{department})")
    void insertFiles(Files file);

    // Update修改接口
    @Update("UPDATE files SET name=#{name}, username=#{username}, position=#{position}, " +
            "level=#{level}, date=#{date}, phone=#{phone}, email=#{email}, department=#{department} WHERE id=#{id}")
    void updateFiles(Files file);

    // Delete删除接口
    @Delete("DELETE FROM files WHERE id = #{id}")
    void deleteFiles(Long id);
}
